Skip to content

Conversation

@abanchev
Copy link

If you have very big trees, sometimes the recursion causes the call stack size to exceed its limit

Converted the calls to use iterative approach instead

@eyas-ranjous eyas-ranjous self-assigned this Feb 28, 2024
@eyas-ranjous
Copy link
Member

@abanchev thanks for making these changes. the recursive version of the BST is a kind of the standard one for most of devs, and i would like to keep it around. if you can create a new type of the tree that works without recursion like BinarySearchTreeIterative & AvlTreeIterative, that'd be nice.

@andy0130tw
Copy link

andy0130tw commented Aug 11, 2025

@abanchev We have run into several "Maximum call stack size exceeded" errors using this BST package, while your patch works well. Do you have any plan to publish your fork to npm? Thanks!

@abanchev
Copy link
Author

@andy0130tw not really, you can publish it if you care to, or you can refactor it with a new name and submit a PR here

@eyas-ranjous
Copy link
Member

@andy0130tw I can add the implementation here. But not by modifying the existing insert. Can you please open a feature request in the repo. Thanks

@andy0130tw
Copy link

@eyas-ranjous Got it. I will open one shortly. In the meantime, I’ll work on incorporating @abanchev's work into the project. Appreciate the help from both of you!

@eyas-ranjous
Copy link
Member

the iterative feature is now available in v5.4.0

Docs: https://datastructures-js.info/docs/binary-search-tree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants